Patent document 1 discloses an exemplary semiconductor device having a current sensing function. Patent document 1 includes a main element domain and a sense element domain connected in parallel with the main element domain. A plurality of main elements is formed in the main element domain, and a plurality of sense elements is formed in the sense element domain. Current flowing through the semiconductor device is divided into a main current flowing through the main element domain and a sense current flowing through the sense element domain. A main current value is a value corresponding to the number of main elements, and a sense current value is a value corresponding to the number of sense elements. Accordingly, a current sense ratio obtained by dividing the main current value by the sense current value is constant. Thus, if the value of the sense current flowing through the sense element domain is measured, the main current value can be calculated from the measured sense current value and the current sense ratio.